package com.atguigu.scala.chapter7
import scala.collection.mutable
/**
 * @author lizikuan
 * @date 2021/5/24 11:14
 */
object $05_Map extends App {
  //不可变map
  val map = Map("aa" -> 1, "bb" -> 2, "cc" -> 3)
  val map1 = map.+("dd" -> 4)
  println(map)
  println(map1)
  println("----------------------------------------")
  //不可变map有序
  private val map2: Map[String, Int] = map.++(Map(("gg", 1)))
  println(map2)
  private val map3: Map[String, Int] = map.++:(Map(("gg", 1)))
  println(map3)
  //可变map
  private val mmap1: mutable.Map[String, Int] = mutable.Map("aa" -> 10, "bb" -> 11, "cc" -> 12,"dd"->0)
  private val i: Int = mmap1.apply("dd")
  private val option: Option[Int] = mmap1.get("aa")
  private val value: Int = option.get
  println(value)

  private val mmap2= mmap1.+=("ee" -> 1)
  //可变map无序
  println(mmap1.++:(Map("ff" -> 3)))
  println(mmap1.++(Map("ff" -> 3)))

}
